package com.wenan.ui.reports
{
	import com.wenan.data.ParameterCollection;
	import com.wenan.ui.controls.charts.Linear;
	
	import mx.collections.ArrayCollection;
	import mx.containers.Box;
	import mx.controls.Alert;
	import mx.core.UIComponent;

	public class TimeComparisonReportInfo extends ReportInfo
	{
		private var linear:Linear;
		private var _xField:String;
		private var _yFields:Array;
		
		public function TimeComparisonReportInfo()
		{
			super();
		}
		
		public override function get title():String
		{
			return "线状图";
		}
		
		public override function get xField():String
		{
			return _xField;
		}
		
		public override function set xField(value:String):void
		{
			_xField = value;
		}
		
		public override function get yFields():Array
		{
			return _yFields;
		}
		
		public override function set yFields(value:Array):void
		{
			_yFields = value;
		}
		
		public override function createReportPanel():UIComponent {
			linear = new Linear();
			
			var chartSty:ParameterCollection = reportData.reportStyle;
			linear.dataProvider = reportData.dataProvider;
			if (chartSty && chartSty.length > 0)
			{
				var charts:ParameterCollection =  chartSty.getObj("线状图") as ParameterCollection;
				if (!charts)
				{
					Alert.show("找不到此报表的渲染信息！");
					return new Box();
				}
				
				linear.dataProvider = reportData.dataProvider;
				linear.xListData = charts.getObj("xSelectableFields") as ArrayCollection;
				linear.xLabelField = "title";
				
				linear.yListData = charts.getObj("ySelectableFields") as ArrayCollection;
				linear.yLabelField = "title";
				
				linear.categoryField = charts.getObj("xDefaultField") as String;
				linear.valueDescribeList = (charts.getObj("yDefaultFields") as ArrayCollection);
				linear.xHeading.title = charts.getObj("reportStyle").axisX;
				linear.yHeading.title = charts.getObj("reportStyle").axisY;
				linear.titleName = charts.getObj("reportStyle").title;
				linear.titleSize = 20;
				for each (var obj:Object in charts.getObj("yDefaultFields") as ArrayCollection)
				{
					linear.colors.addItem(obj.color);
				}
			}
	
			return linear.createReportPanel();
		}
	}
}